

include config.mak

OBJECTS=node.o
TEST_PROGS=node_test
INCLUDE=-I.
NNET_LIBS=-lm -lc
LIBS=-L.

LD_FLAGS=-shared -soname libnnet.so -o libnnet.so.$(VERSION)

### Main targets

all: nnet-info nnet $(TEST_PROGS)
	cp $(TEST_PROGS) ../bin
	cp -f libnnet.so.$(VERSION) ../bin
	cd ../bin && ldconfig -v -n .

nnet: $(OBJECTS)
	ld $(LD_FLAGS) $(NNET_LIBS) $(OBJECTS)
	ldconfig -v -n .

### Source compiling targets

.c: nnet
	$(CC) $(C_TEST_FLAGS) -o $@ $(CPP_FLAGS) $(INCLUDE) $(LIBS) $<

.c.o:
	$(CC) $(C_FLAGS) $(CPP_FLAGS) $(INCLUDE) $<

### Other targets

nnet-info:
	@echo "+----------------------------------------------------------+"
	@echo "Building physm version $(VERSION)"
	@echo "  CC:           $(CC)"
	@echo "  C_FLAGS:      $(C_FLAGS)"
	@echo "  C_TEST_FLAGS: $(C_TEST_FLAGS)"
	@echo "  CPP_FLAGS:    $(CPP_FLAGS)"
	@echo "  OBJECTS:      $(OBJECTS)"
	@echo "  TEST_PROGS:   $(TEST_PROGS)"
	@echo "  INCLUDE:      $(INCLUDE)"
	@echo "  LIBS:         $(LIBS)"

### Cleaning targets

clean: clean-src

clean-src:
	rm -f *.o
	rm -f libnnet*
	rm -f $(TEST_PROGS)
